#include "Dog.h"
#include <iostream>
#include <functional>
#include <thread>
#include <memory>
#include <chrono>

using namespace std;

int main() {
//作用域：1. 空间范围；2. 时间范围<多线程>
    {
        Dog dog1;
        Dog& dog2 = dog1;
        dog1.sleep();
        // 引用与指针：
        // 1. 指针 if(NULL == ptr)
        // 2. 引用
        //
        function<void(Dog)> func =  [&dog1](Dog dog2){
            while(1){dog1.sleep();
            this_thread::sleep_for(chrono::seconds(5));
            }
        };
        func(dog1);
        dog1.sleep();
        thread thd([&dog1]{
            for(int i = 0; i < 5; ++i){
                dog1.sleep();
            // this_thread::sleep_for(chrono::seconds(1));
            }
        });
    }
    this_thread::sleep_for(chrono::seconds(10));
        // dog1.sleep();
    cout << "leave" << endl;
    return 0;
}